package com.liudachu.interview.bishi;

import java.util.Scanner;

/**
 * 压缩字符串操作
 */
public class ZipStr {

    public static String zipString(String iniString) {
        StringBuilder sb = new StringBuilder();
        int len = iniString.length();
        int low = 0, high = 0;
        int count = 0;
        char c = ' ';

        while(low < len){
            high = low;
            c = iniString.charAt(low);
            while((high < len) && (iniString.charAt(high) == c)){
                high++;
            }
            count = high - low;
            if (count==1){
                sb.append(c);
                low = high;
                continue;
            }
            sb.append(count);
            sb.append(c);
            low = high;
        }

        return (sb.toString().length() < len) ? sb.toString() : iniString;
    }


    public static void main(String[] args) {
        Scanner sr = new Scanner(System.in);
        String str = sr.next();
        String str2 = sr.next();
        System.out.println(zipString(str));
        System.out.println(zipString(str2));



    }

}
